package Text29;

import java.util.*;

public class Main {
    static int N = 1010;
    static Sphere[] spheres = new Sphere[N];
    static int[] p = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        while (T-- > 0) {
            int n = in.nextInt();
            int h = in.nextInt();
            int r = in.nextInt();
            for (int i = 0; i <= n + 1; i++) {
                p[i] = i;
            }
            for (int i = 1; i <= n; i++) {
                int x = in.nextInt();
                int y = in.nextInt();
                int z = in.nextInt();
                spheres[i] = new Sphere(x, y, z);
                if (Math.abs(z) <= r) {
                    p[find(i)] = find(0);
                }
                if (Math.abs(h - z) <= r) {
                    p[find(i)] = find(n + 1);
                }
            }
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    long dx = spheres[i].x - spheres[j].x;
                    long dy = spheres[i].y - spheres[j].y;
                    long dz = spheres[i].z - spheres[j].z;
                    if (dx * dx + dy * dy + dz * dz <= 4 * (long) r * r) {
                        p[find(i)] = find(j);
                    }
                }
            }
            if (find(0) == find(n + 1)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }

    private static int find(int x) {
        if (x != p[x]) {
            p[x] = find(p[x]);
        }
        return p[x];
    }
}

class Sphere {
    int x, y, z;

    public Sphere(int x, int y, int z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }
}
